{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}addhosts{% endblock %}
{% block content %}
    <div style="margin: 25px">
    <form action="" method="post" class="form-inline">
        <div class="form-group">
            <label>主机名：</label><input type="text" class="form-control" name="host">
        </div>
        <div class="form-group">
            <label> ip地址：</label><input type="text" class="form-control" name="ipaddr">
        </div>
        <div class="form-group">
            <label> 主机组：</label><input type="text" class="form-control" name="hostgroup">
        </div>

        <input type="submit" value="提交" class="btn-primary">
    </form>
    </div>

    <table class="table table-bordered table-striped table-hover">
        <tr class="text-center alert-info">
            <td>主机组</td>
            <td>主机</td>
        </tr>
{#        {% for hostname in hostnames %}#}
{#            <tr class="text-center">#}
{#                <td>{{ hostname.group.groupname }}</td>#}
{#                <td>{{ hostname.hostname }}</td>#}
{#                <td>{{ hostname.ipaddr }}</td>#}
{#            </tr>#}
{#        {% endfor %}#}
    {% for group in hostgroup %}
        <tr class="text-center">
            <td class="text-center">{{ group.groupname }}</td>

                <td class="text-center">
                    <ul class="list-unstyled">
                    {% for host in group.host_set.all %}

                        <li>{{ host.hostname }}:{{ host.ipaddr }}</li>

                    {% endfor %}
                    </ul>
                </td>

        </tr>
    {% endfor %}

    </table>
{% endblock %}